#include<stdio.h>
#include<string.h>
#include<unistd.h>
#include <fcntl.h>
#define MY_WRONLY 1
#define MY_RDONLY 2
#define MY_CREAT 4
#define MY_APPEND 8

void show(int flag)
{
	if(flag&MY_WRONLY)
	{
		printf("只读模式\n");
	}
	if(flag&MY_RDONLY)
	{
		printf("只写模式\n");
	}
	if(flag&MY_CREAT)
	{
		printf("创建文件\n");
	}
	if(flag&MY_APPEND)
	{
		printf("追加打开\n");
	}
	return ;
}
int main()
{
	//show(MY_WRONLY|MY_CREAT);
	FILE*pf = fopen("code.txt","w");//已写的方式打开
	if(!pf)
	{
		//open fail
		perror("fopen");
	}
	//open succssese
	//write file;
	char*ch = "hello worldfjdjfsdjfdsjfdsj\n";
//	fwrite(ch,strlen(ch),1,pf);
	fputs(ch,pf);
	printf("%ld\n",sizeof(ch));
	printf("%ld\n",strlen(ch));
	fclose(pf);
	
}
